package com.hs.jpademo1.aop;

import com.hs.jpademo1.annotation.MyLog;
import net.bytebuddy.asm.Advice;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;

/**
 * @ClassName SelectAop
 * @Description TODO
 * @Author 郭敖
 * @Date 2023年10月23日 20:08
 * @Version 1.0
 */
@Aspect
@Component
public class SelectAop {

    //around会拦截结果可以通过返回结果释放
    @Around(value = "@annotation(log)", argNames = "pjp,log")
    public Object before(ProceedingJoinPoint pjp, MyLog log) throws Throwable {
        System.out.println("查询开始！！！"+log.value()+"=====>");
        System.out.println(pjp.proceed());
        return pjp.proceed();
    }

    @AfterReturning(value = "@annotation(log)")
    public void afterReturn(JoinPoint point,MyLog log){
        System.out.println("返回增强=========>"+point.getTarget());
    }
}
